package com.gxuwz.easyschool.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.gxuwz.easyschool.R;
import com.gxuwz.easyschool.holder.MessageHolder;

public class MessageAdapter extends BaseAdapter {
    private String[] names = {"[支付中心]一卡通充值","[支付中心]一卡通充值","[支付中心]一卡通充值"};
    private String[] types = {"系统通知","系统通知","系统通知"};
    private String[] status = {"农行支付，支付成功","农行支付，支付成功","农行支付，支付成功"};
    private String[] moneys = {"￥150","￥150","￥150"};
    private String[] times = {"10分钟前","10分钟前","10分钟前"};
    private Context context;
    public MessageAdapter(Context context){
        this.context = context;
    }

    @Override
    public int getCount() {
        return names.length;
    }

    @Override
    public Object getItem(int position) {
        return names[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MessageHolder messageHolder = null;
        if(convertView == null){
//            convertView = View.inflate(context,R.layout.message_list,null);
            convertView = LayoutInflater.from(context).inflate(R.layout.message_list,null);
            messageHolder = new MessageHolder();
            messageHolder.setMessage_name(convertView.findViewById(R.id.message_name));
            messageHolder.setMessage_type(convertView.findViewById(R.id.message_type));
            messageHolder.setMessage_status(convertView.findViewById(R.id.message_status));
            messageHolder.setMessage_money(convertView.findViewById(R.id.message_money));
            messageHolder.setMessage_time(convertView.findViewById(R.id.message_time));
            convertView.setTag(messageHolder);
        } else {
            messageHolder = (MessageHolder) convertView.getTag();
        }
        messageHolder.getMessage_name().setText(names[position]);
        messageHolder.getMessage_type().setText(types[position]);
        messageHolder.getMessage_status().setText(status[position]);
        messageHolder.getMessage_money().setText(moneys[position]);
        messageHolder.getMessage_time().setText(times[position]);
        return convertView;
    }
}
